﻿using System;

namespace BrowserXP
{
    public class SingleInstanceApplicationWrapper : Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase
    {
        public SingleInstanceApplicationWrapper()
        {
            this.IsSingleInstance = true;   //启用单实例模式
        }

        //创建WPF应用程序类。
        private BrowserApp app;
        protected override bool OnStartup(Microsoft.VisualBasic.ApplicationServices.StartupEventArgs e)
        {
            app = new BrowserApp();
            //app.StartupUri = new Uri("MainWindow.xaml", UriKind.Relative);
            app.StartupUri = new Uri("MainNotifyWindow.xaml", UriKind.Relative);
            app.Run();
            return false;
        }

        //多个实例
        protected override void OnStartupNextInstance(Microsoft.VisualBasic.ApplicationServices.StartupNextInstanceEventArgs e)
        {
            if (e.CommandLine.Count > 0)
                app.ShowBusinessWindow(e.CommandLine[0]);
        }
    }
}
